const { defineConfig } = require("@vue/cli-service")
module.exports = defineConfig({
  lintOnSave: false,
  transpileDependencies: true,
  configureWebpack: {
    resolve: {
      alias: {
        '@': require('path').resolve(__dirname, 'src')
      }
    },
    devtool: 'source-map',
    devServer: {
      client: {
        webSocketURL: 'wss://flying-crawdad-smashing.ngrok-free.app/ws'
      },
      allowedHosts: 'all',
      proxy: {
        '/api/auth': {
          target: 'http://localhost:8083',
          changeOrigin: true
        },
        '/api/neo4j': {
          target: 'http://localhost:8082',
          changeOrigin: true
        }
      }
    },
    optimization: {
      splitChunks: {
        chunks: 'all',
        maxInitialRequests: Infinity,
        minSize: 20000,
        cacheGroups: {
          vendor: {
            test: /[\\/]node_modules[\\/]/,
            name(module) {
              const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
              return `npm.${packageName.replace('@', '')}`;
            }
          }
        }
      }
    }
  },
  chainWebpack(config) {
    config.plugin('define').tap((definitions) => {
      Object.assign(definitions[0], {
        __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(false),
        __VUE_OPTIONS_API__: JSON.stringify(true),
        __VUE_PROD_DEVTOOLS__: JSON.stringify(false)
      })
      return definitions
    })
  }
})
